package lab01;

import java.util.Random;
import java.util.Scanner;

public class Test08 {

        public static void main(String[] args) {

            int rightNum = new Random().nextInt(100) + 1;

            int input ;

            System.out.println("猜数字游戏开始了！");

            Scanner scanner = new Scanner(System.in);

            System.out.print("请输入数字(1-100)：");

            do {

                input = scanner.nextInt();

                if(input < rightNum){

                    System.out.println("猜小了!请重新输入：");
                }
                else if(input > rightNum){

                    System.out.println("猜大了!请重新输入：");
                }
            }while(input != rightNum);

            System.out.println("猜对了！正确数字为：" + rightNum);

        }
    }

